const $sequenceClient = require('@mctech/infra-sdk').getSequenceClient()

const _MAX_COUNT = 1000

const generalIds = async count => {
  const ids = []
  while (count > 0) {
    const number = count < _MAX_COUNT ? count : _MAX_COUNT
    const range = await $sequenceClient.nexts(number)
    ids.push(...range.toArray())
    count -= _MAX_COUNT
  }
  return ids
}

const generalId = async () => {
  const ids = await generalIds(1)
  return ids[0]
}

module.exports = { generalId, generalIds }
